package com.kefu.call.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author francis
 * @date 2021/05/22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "活动清单")
public class ActivityMyInventoryInfoSearchVo extends AbstractSearchVo {
	
	@ApiModelProperty(value = "活动ID")
	private String activityId;

	@ApiModelProperty(value = "清单状态",example="1",allowableValues="1,2",notes="1 未完成，2已完成")
	private Integer inventoryStatus;
	    
    @ApiModelProperty(value = "清单分配状态",example="1",allowableValues="1,2",notes="1 未分配，2已分配")
    private Integer assignmentStatus;
    
    @ApiModelProperty(value = "意向状态",example="0",allowableValues="0,1,2,3,4",notes="0 无，1 无效电话，2无意向，3 意向，4已成交")
    private Integer intentionStatus;
	
	@ApiModelProperty(value = "客户姓名")
	private String customerName;
	
	@ApiModelProperty(value = "客户电话")
	private String customerPhone;

	@ApiModelProperty(value = "清单备注")
	private String inventoryDesp;
	 

    public <T>QueryWrapper<T> builder() {
    	QueryWrapper<T> wrapper=Wrappers.query();
    	if (StringUtils.isNotBlank(activityId)) {
 	        wrapper.eq("activity_id", activityId);
 	    }    
    	
    	if (inventoryStatus!=null) {
		    wrapper.eq("inventory_status", inventoryStatus);
		}
    	if (intentionStatus!=null) {
			wrapper.eq("intention_status", intentionStatus);
		}
		if (assignmentStatus!=null) {
			wrapper.eq("assignment_status", assignmentStatus);
		}
    	
    	if (StrUtil.isNotBlank(customerName)) {
    		wrapper.in("customer_name", customerName);
    	}
		if (StrUtil.isNotBlank(inventoryDesp)) {
			wrapper.like("inventory_desp", inventoryDesp);
		}
    	
    	if (StrUtil.isNotBlank(customerPhone)) {
    		wrapper.in("customer_phone", customerPhone);
    	}
    	
    	
    	wrapper.eq("data_status", 1);
    	
    	wrapper.eq("user_id", KefuContext.getKefuContext().getUserId());
    	
	    return wrapper;
	}
}